package com.bw.module_merchant.activity

import android.os.Bundle
import androidx.fragment.app.activityViewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.blankj.utilcode.util.ToastUtils

import com.bw.module_merchant.adapter.ApproveAdapter

import com.bw.module_merchant.vm.EnterpriseRecordViewModel
import com.example.lib_common.view.view.BaseMvvmFragment
import com.example.module_merchant.R
import com.example.module_merchant.databinding.FragmentApproveTrueBinding


import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class ApproveTrueFragment : BaseMvvmFragment<FragmentApproveTrueBinding>() {
    private val adapter = ApproveAdapter()
    private val viewModel : EnterpriseRecordViewModel by activityViewModels()
    override fun getFragmentState(state: Bundle) {

    }

    override fun saveFragmentState(onState: Bundle) {

    }

    override fun getLayoutId(): Int = R.layout.fragment_approve_true


    override fun initView() {

        binding.rv.adapter = adapter
        binding.rv.layoutManager = LinearLayoutManager(context)

        viewModel.getMerchantRecordList()

        viewModel.mSuccessLiveData.observe(viewLifecycleOwner){
            adapter.data.addAll(it.data.filter { it.status == "已审核" || it.status == "驳回" })
            adapter.notifyDataSetChanged()
        }

        viewModel.mErrorLiveData.observe(viewLifecycleOwner){
            ToastUtils.showLong(it)
        }
    }




}